<script>
import zhCn from 'element-plus/es/locale/lang/zh-cn.mjs'
export default {
  props: ['confimText', 'fromOptions'],
  data() {
    return {
      flag: true,
      lang: zhCn,
    }
  },
  methods: {
    closeDailog() {
      this.flag = false
    },
  },
}
</script>

<template>
  <el-config-provider :locale="lang">
    <!-- 表单通用模态窗 -->
    <el-dialog v-bind="$attrs" v-model="flag">
      <el-form label-width="80px" :inline="false">
        <el-form-item :label="item.label" v-for="item in fromOptions">
          <el-input v-if="item.type == 'text'" :placeholder="item.placeholder"></el-input>
          <el-input
            v-else-if="item.type == 'number'"
            type="number"
            :placeholder="item.placeholder"
          ></el-input>
          <el-date-picker
            class="datetime"
            v-else-if="item.type == 'datetime'"
            type="datetime"
            :placeholder="item.placeholder"
          />
        </el-form-item>
      </el-form>

      <template #footer>
        <el-button @click="closeDailog">取消</el-button>
        <el-button type="primary">{{ confimText }}</el-button>
      </template>
    </el-dialog>
  </el-config-provider>
</template>

<style scoped>
:deep(.datetime) {
  width: 100%;
}
</style>
